'use strict';

const Controller = require('egg').Controller;

class DoFormController extends Controller {
  async index() {
    const { ctx } = this;
    var {type , name , price , detail , img} = ctx.request.body
    var db = this.app.mongodb
    await db.collection(type).insertOne({name,img,detail,price})
    ctx.body = `<script>alert('上传成功！');location.href='/home/${type}'</script>`
  }
}

module.exports = DoFormController;
